using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BUS;
using Entities;
using Utility;

public partial class Admin_NguoiDung_CapNhatNhanVien : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            LoadData();
        }
    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            tbNhanVien nhanvien = tbNhanVienBUS.GetByID(id);
            if (nhanvien != null)
            {
                txt_MaNhanVien.Text = id.ToString();  
                txt_TaiKhoan.Text = nhanvien.TaiKhoan;
                txt_MatKhau.Text = nhanvien.MatKhau;
                txt_TenNhanVien.Text = nhanvien.TenNV;
                txt_DiaChi.Text = nhanvien.DiaChi;
                txt_DienThoai.Text = nhanvien .DienThoai ;
            }
        }
        catch
        {
            Response.Redirect("~/Admin/NguoiDung/DanhSachNhanVien.aspx");
        }

    }
    protected void btn_luu_Click(object sender, EventArgs e)
    {
        try
        {
            tbNhanVien nhanvien = new tbNhanVien();
            nhanvien.MaNV = int.Parse(txt_MaNhanVien.Text); 
            nhanvien.TaiKhoan = txt_TaiKhoan.Text;
            nhanvien.MatKhau = txt_MatKhau.Text;
            nhanvien.TenNV = txt_TenNhanVien.Text;
            nhanvien.DiaChi = txt_DiaChi.Text;
            nhanvien.DienThoai = txt_DienThoai.Text;
            tbNhanVienBUS.UpDate(nhanvien);
        }
        catch
        {
            Response.Redirect("~/Admin/NguoiDung/DanhSachNhanVien.aspx");
        }
        Response.Redirect("~/Admin/NguoiDung/DanhSachNhanVien.aspx");

    }
}
